// import webIm from "@/utils/library/webIm.1.0.0.js"
const state = {
	userid: "0",
	islogin: false,
	userinfo: {},
	company: {},
	// 账号密码登录的登录表单
	userloginform: {},
	confirmInfo: [], //确认订单信息
	statusBarHeight1: '',
	// 已读信息条数
	messageNum: 0,
	// 会员等级颜色
	colors: [{
			bgColor: "#E9EFEF",
			wordColor: "#60807D",
			lineColor: "#B6C4C3",
			level: "青铜会员"
		},
		{
			bgColor: "#F7F7F7",
			wordColor: "#A3AAB0",
			lineColor: "#D2D9E0",
			level: "白银会员"
		},
		{
			bgColor: "#FFF8DE",
			wordColor: "#CEAB21",
			lineColor: "#D3CAB2",
			level: "黄金会员"
		},
		{
			bgColor: "#EDFAFF",
			wordColor: "#59B0E6",
			lineColor: "#BBD0DB",
			level: "铂金会员"
		},
		{
			bgColor: "#F2F5FF",
			wordColor: "#284EB6",
			lineColor: "#C1CBEF",
			level: "钻石会员"
		},
		{
			bgColor: "#FDF7FF",
			wordColor: "#A877C6",
			lineColor: "#DBC6E8",
			level: "钻石Ⅰ会员"
		},
		{
			bgColor: "#F8F2FF",
			wordColor: "#78439F",
			lineColor: "#958AC3",
			level: "钻石Ⅱ会员"
		},
		{
			bgColor: "#F4F2F2",
			wordColor: "#8D4581",
			lineColor: "#907B8C",
			level: "钻石Ⅲ会员"
		},
		{
			bgColor: "#F4F2F2",
			wordColor: "#502E30",
			lineColor: "#795D5E",
			level: "王者会员"
		},
	],
	userAuditStatus: null, // 用户审核状态
	userIdentityType: null, // 用户身份类型
}
const mutations = {
	// 设置信息条数
	SET_MESSAGENUM: (state, messageNum) => {
		console.log('SET_MESSAGENUM')
		state.messageNum = messageNum
	},
	// 设置登录信息
	SET_USERLOGINFORM: (state, userloginform) => {
		state.userloginform = userloginform
	},
	// 设置用户信息
	SET_USERINFO: (state, userinfo) => {
		state.userinfo = userinfo
		state.userid = userinfo.id || 0;
		state.islogin = true
	},
	// 设置公司信息
	SET_COMPANY: (state, company) => {
		state.company = company;
		state.id_dw = company ? company.id_dw : 0;
	},
	//设置确认订单信息
	SET_CONFIRMINFO: (state, confirmInfo) => {
		state.confirmInfo = confirmInfo;
	},
	SET_statusBarHeight: (state, statusBarHeight1) => {
		state.statusBarHeight1 = statusBarHeight1;
	},
	// 设置用户的审核信息
	SET_USERAUDITSTATUS: (state, userAuditStatus) => {
		state.userAuditStatus = userAuditStatus;
	},
	// 设置用户的身份信息
	SET_USERIDENTITYTYPE: (state, userIdentityType) => {
		state.userIdentityType = userIdentityType;
	},
}
const actions = {
	login({
		commit,
		dispatch
	}, userloginform) {
		return new Promise((resolve, reject) => {
			state.islogin = true;
			commit('SET_USERINFO', userloginform)
			// console.log(state.userid);
		})
	},
	setBar({
		commit,
		dispatch
	}, userloginform) {
		return new Promise((resolve, reject) => {
			// console.log('23423423',userloginform);
			commit('SET_statusBarHeight', userloginform)
			// console.log(state.userid);
		})
	},
	logout({
		commit,
		state,
		dispatch
	}) {
		uni.removeStorageSync('token');
		commit('SET_COMPANY', {})
		// 存储用户信息
		commit('SET_USERINFO', {});
		commit('SET_USERLOGINFORM', {});
		state.islogin = false;
		commit('SET_CONFIRMINFO', []);
		// webIm.close();
	},
	setUserAuditStatus({
		commit
	}, userAuditStatus) {
		commit('SET_USERAUDITSTATUS', userAuditStatus);
	},
	setUserIdentityType({
		commit
	}, userIdentityType) {
		commit('SET_USERIDENTITYTYPE', userIdentityType);
	},
}
export default {
	namespaced: true,
	state,
	mutations,
	actions
}